package framework.util.shiro;

import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

import javax.annotation.Resource;

/**
 * @author 吴宇亮 on 2019/12/22 19:46
 */
public class ShiroInit implements ApplicationContextAware {

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        //禁止shiro给url后拼接JSESSIONID
        DefaultWebSecurityManager securityManager = applicationContext.getBean(DefaultWebSecurityManager.class);
        DefaultWebSessionManager sessionManager = (DefaultWebSessionManager) securityManager.getSessionManager();
        sessionManager.setSessionIdUrlRewritingEnabled(false);
    }
}
